<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">

<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/h-ui.admin/css/H-ui.admin.css" />
<script type="text/javascript" src="__PUBLIC__/Admin/js1/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<title>设置权限</title>
</head>
<body>
<article class="cl pd-20">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设置权限</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$name}" style="width:100px">
			</div>
			&nbsp;&nbsp;
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">权限列表：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<dl class="permission-list">
					<dt>
						<label>
							<input type="checkbox" value="" name="user-Character-0" id="user-Character-0">
							权限管理</label>
					</dt>
					<if condition="$accessOb">
					    <foreach name="accessOb" item="v">
					<dd>
						<dl class="cl permission-list2">
							<dt>
								<label class="">
	                            <input type="checkbox" name="role_ids[]" value="{$v.id}" style="margin-left:120px" checked="checked"/>
								<in name="v.id" value="$access_id">1</in>
								
								
								   {$v.title}
									</label>
								
							</dt>
							<dd>
								
							</dd>
						</dl>
					</dd>
					</foreach>
				</if>
			    </div>
		     </div>
		     
		     <foreach name="role_access_id" item="v">
		     {$v.access_id}
		     </foreach>
		     
		     
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			    <input type="hidden" name="id" value="{$id}"/>
				<button class="btn btn-success radius" id="commit" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
			</div>
		</div>

</article>
<script>
$('#commit').click(function(){
	 var role_id = $("input:hidden[name='id']").val();

	 var  access_id=[];
	$(':checkbox').each( function() {
		if( $(this).prop('checked')) {
			access_id.push( $(this).val());
		} 
	})
	
     $.post('__APP__/Admin/Role/role_access',{access_id:access_id,role_id:role_id},function(obj){
	       if(obj.pass==1) {
	    	var index=layer.msg(obj.msg,{time:1000,icon:1},function(){
	    		parent.layer.close(index);
				window.parent.location.reload();
	    	});
	       }
     },'json')
})
</script>
</body>
</html>